//
//  HomeStartController.m
//  DigitalFlip
//
//  Created by 蓝鳍互娱 on 2024/1/23.
//

#import "HomeStartController.h"
#import "Public.h"
#import "HomeModelSelectView.h"
#import "GameSelectController.h"
@interface HomeStartController ()
@property (nonatomic,strong) HomeModelSelectView *homeModelSelectView;
@end

@implementation HomeStartController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColor.clearColor;
    [self creatSubView];
}
- (void)creatSubView{
    UIImageView * homeStartBgImgView = [[UIImageView alloc] init];
    homeStartBgImgView.image = DFImageNamed(@"homeStartBg");
    homeStartBgImgView.alpha = 0.5;
    homeStartBgImgView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:homeStartBgImgView];
    [homeStartBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(ScreenAutoScale(0)));
    }];
    UIImageView * homeHeadImgView = [[UIImageView alloc] init];
    homeHeadImgView.image = DFImageNamed(@"homeHeadIcon");
    [self.view addSubview:homeHeadImgView];
    [homeHeadImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(@(ScreenAutoScale(100)+df_TopSafeH));
        make.width.equalTo(@(ScreenAutoScale(100)));
        make.height.equalTo(@(ScreenAutoScale(100)));
    }];
    UILabel * homeAlertLab = [[UILabel alloc] init];
    homeAlertLab.font = [UIFont systemFontOfSize:40 weight:UIFontWeightSemibold];
    homeAlertLab.textColor = df_ColorRGB(0xFFFFFF);
    homeAlertLab.text = @"Challenge";
    homeAlertLab.textAlignment = NSTextAlignmentCenter;
    homeAlertLab.numberOfLines = 0;
    homeAlertLab.alpha = 0;
    [self.view addSubview:homeAlertLab];
    [homeAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(homeHeadImgView.mas_bottom).offset(ScreenAutoScale(50));
    }];
    [UIView animateWithDuration:1 animations:^{
        homeAlertLab.alpha = 1;
    }];
    UILabel * homeAlertBottomLab = [[UILabel alloc] init];
    homeAlertBottomLab.font = [UIFont systemFontOfSize:30 weight:UIFontWeightSemibold];
    homeAlertBottomLab.textColor = df_ColorRGB(0xFFFFFF);
    homeAlertBottomLab.text = @"never gives up!";
    homeAlertBottomLab.textAlignment = NSTextAlignmentCenter;
    homeAlertBottomLab.numberOfLines = 0;
    homeAlertBottomLab.alpha = 0;
    [self.view addSubview:homeAlertBottomLab];
    [homeAlertBottomLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(homeAlertLab.mas_bottom).offset(ScreenAutoScale(10));
    }];
    [UIView animateWithDuration:1 delay:1.5 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        homeAlertBottomLab.alpha = 1;
    } completion:^(BOOL finished) {
        
    }];
    
    self.homeModelSelectView = [[HomeModelSelectView alloc] init];
    self.homeModelSelectView.alpha = 0;
    [self.view addSubview:self.homeModelSelectView];
    [self.homeModelSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-ScreenAutoScale(50)));
        make.left.equalTo(@(ScreenAutoScale(50)));
        make.top.equalTo(homeAlertBottomLab.mas_bottom).offset(ScreenAutoScale(70));
        make.height.equalTo(@(ScreenAutoScale(50)));
    }];
    [UIView animateWithDuration:1 delay:3 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.homeModelSelectView.alpha = 1;
    } completion:^(BOOL finished) {
        
    }];
    
    UIButton * homeStartBtn = [[UIButton alloc] init];
    [homeStartBtn setTitle:@"Start" forState:UIControlStateNormal];
    [homeStartBtn setTitleColor:df_ColorRGB(0xFFFFFF) forState:UIControlStateNormal];
    homeStartBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
    [homeStartBtn addTarget:self action:@selector(homeStart) forControlEvents:UIControlEventTouchUpInside];
    [homeStartBtn setBackgroundColor:df_ColorRGBA(0xFFFFFF, 0.1)];
    homeStartBtn.alpha = 0;
    homeStartBtn.layer.cornerRadius = ScreenAutoScale(40);
    homeStartBtn.clipsToBounds = YES;
    [self.view addSubview:homeStartBtn];
    [homeStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(@(-ScreenAutoScale(100)));
        make.centerX.equalTo(self.view);
        make.height.equalTo(@(ScreenAutoScale(80)));
        make.width.equalTo(@(ScreenAutoScale(80)));
    }];
    [UIView animateWithDuration:1 delay:3 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        homeStartBtn.alpha = 1;
    } completion:^(BOOL finished) {
        
    }];
}
- (void)homeStart{
    GameSelectController * gameSelectCtrl = [[GameSelectController alloc] init];
    [self.navigationController pushViewController:gameSelectCtrl animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
